clear all 
drop _all 
global seed 12345 
global ctr randgpa topemp secondint wfm techskills  
global dem WhiteFemale MinorityFemale MinorityMale
global fe i.resumenum i.subjectid i.majorid i.lead1 i.lead2

grstyle init 
grstyle set plain, hor 

//cd "Your Path"
 
**================**
** Tab 1
**================**

use "IRR_cleaned_data.dta", clear 

	local name Tab1_Overall_Effect
	qui reghdfe rating_hire WhiteMale_prev $ctr $dem, a( subjectid)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label  addtext(Subject fixed effects, Yes, Major fixed effects, No,  Leadership fixed effects, No, Order fixed effects, No) ctitle(" ") replace nonotes 

	qui reghdfe rating_hire WhiteMale_prev $ctr $dem, a(majorid subjectid)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label  addtext(Subject fixed effects, Yes, Major fixed effects, Yes,  Leadership fixed effects, No, Order fixed effects, No) ctitle(" ")  

	qui reghdfe rating_hire WhiteMale_prev $ctr $dem, a(majorid lead1 lead2 subjectid)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label  addtext(Subject fixed effects, Yes, Major fixed effects, Yes, Leadership fixed effects, Yes, Order fixed effects, No) ctitle(" ")
	
	qui reghdfe rating_hire WhiteMale_prev $ctr $dem, a(majorid lead1 lead2 resumenum subjectid)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label  addtext(Subject fixed effects, Yes, Major fixed effects, Yes, Leadership fixed effects, Yes, Order fixed effects, Yes) ctitle(" ")

	qui reghdfe rating_hire WhiteMale_prev $ctr $dem randgpa_prev topemp_prev secondint_prev wfm_prev techskills_prev , a(majorid lead1 lead2 resumenum subjectid)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label addtext(Subject fixed effects, Yes, Major fixed effects, Yes, Leadership fixed effects, Yes, Order fixed effects, Yes) ctitle(" ") nonotes

	** mention this result in footnote #9: 
	reghdfe rating_hire LQWhiteMale_prev HQWhiteMale_prev $ctr $dem , a(majorid lead1 lead2 resumenum subjectid)  vce(r)


**================**
** Fig 1
**================**

use "IRR_cleaned_data.dta", clear 

   	eststo low:  	qui reghdfe rating_hire WhiteMale $ctr if LQType, a($fe) vce(r) 
  	eststo high: 	qui reghdfe rating_hire WhiteMale $ctr if !LQType, a($fe) vce(r) 
	eststo alow:  	qui reghdfe rating_hire WhiteMale_prev $ctr $dem if LQType_prev , a($fe) vce(r)
 	eststo ahigh: 	qui reghdfe rating_hire WhiteMale_prev $ctr $dem  if !LQType_prev, a($fe) vce(r)

	coefplot low high, ///
	keep(WhiteMale) mc(black) ciopts(color(black)) msymbol(c) xline(0,lc(gray)) level(95) grid(none) xlab(-.3(.23).6, labs(small) format(%2.1f)) msize(small) ysca(off) xtitle("b(Being White Man)", size(med) margin(t=1)) legend(order(2 "Low-Quality" 4  "High-Quality") col(1) pos(9) size(med) rowg(20) region(color(none) margin(b=3))) name(wm, replace)  mlabel mlabpos(12) mlabc(black) format(%4.3f) mlabgap(*2) mlabsize(medlarge) msize(med) title("(a) Effect of Being a White Man", size(medlarge) margin(b=10)) graphregion(margin(l=0 r=7))
	
	coefplot alow ahigh, ///
	keep(WhiteMale_prev) mc(black) ciopts(color(black)) msymbol(d) xline(0,lc(gray)) level(95) grid(none) xlab(-.9(.3).3, labs(small) format(%2.1f)) msize(small) ysca(off) xtitle("b(After White Man)", size(med) margin(t=1)) legend(order(2 "After Low-Quality 	"  4 "After High-Quality") col(1) pos(9) size(med) rowg(20) region(color(none) margin(b=3))) name(wm_prev, replace)  mlabel mlabpos(12) format(%4.3f) mlabgap(*2) mlabsize(medlarge) msize(med) title("(b) Effect of Being After a White Man	", size(medlarge) margin(b=10)) graphregion(margin(l=5 r=1)) mlabc(black)
	 
	graph combine wm wm_prev, ycomm 
	graph display, ysize(10) xsize(15)
  	graph export "./output/Fig1_by_quality.pdf", replace 

	** magnitude of the effect 
	sum rating_hire if !WhiteMale & !LQType
	sum rating_hire if !WhiteMale_prev
	dis .318/5.167 	//=.615
	dis .318/2.6	//=.122
	dis .526/2.6 	//=17% SD 
	dis .526/2.17 	//=.24 GPA points 
	dis .526/4.76 	//=11% of Mean of control group 
	
	** test the difference in coefficients  
 	eststo Low: 	qui reg rating_hire WhiteMale $ctr $fe if LQType  
  	eststo High: 	qui reg rating_hire WhiteMale $ctr $fe if !LQType 
 	eststo aLow: 	qui reg rating_hire WhiteMale_prev $ctr $dem $fe if LQType_prev  
 	eststo aHigh:	qui reg rating_hire WhiteMale_prev $ctr $dem $fe if !LQType_prev 

	qui suest Low High , vce(r)
	test [Low_mean]WhiteMale= [High_mean]WhiteMale 
		//pval=.0108
	qui suest aLow aHigh, vce(r)
	test [aLow_mean]WhiteMale_prev= [aHigh_mean]WhiteMale_prev 
		//pval=.0032

**================**
** Fig 2
**================**

use "IRR_cleaned_data.dta", clear 

	gen STEM=(major_type==1)
   	eststo s1:  	qui reghdfe rating_hire WhiteMale $ctr if STEM, a($fe) vce(r) 
  	eststo ns1:  	qui reghdfe rating_hire WhiteMale $ctr if !STEM, a($fe) vce(r) 
	eststo s2:   	qui reghdfe rating_hire WhiteMale_prev $ctr $dem if STEM , a($fe) vce(r)
 	eststo ns2:  	qui reghdfe rating_hire WhiteMale_prev $ctr $dem  if !STEM, a($fe) vce(r)
 	eststo s2l:   	qui reghdfe rating_hire LQWhiteMale_prev $ctr $dem if STEM , a($fe) vce(r)
 	eststo ns2l:  	qui reghdfe rating_hire LQWhiteMale_prev $ctr $dem  if !STEM, a($fe) vce(r)

	coefplot  ns1 s1, ///
	keep(WhiteMale) mc(black) ciopts(color(black)) msymbol(c) xline(0, lc(gray)) level(95) grid(none) xlab(-.2(.2).8, labs(small) format(%2.1f)) msize(small) ysca(off) xtitle("b(Being White Man)", size(med) margin(t=1)) legend(order(2  "HSB Industries" 4 "STEM Industries" ) col(1) pos(9) size(med) rowg(20) region(color(none) margin(b=3))) name(wm, replace)  mlabel mlabpos(12) format(%4.3f) mlabgap(*2) mlabsize(medlarge) msize(med) title("(a) Effect of Being a White Man", size(medlarge) margin(b=10)) graphregion(margin(l=0 r=7)) mlabc(black)
	
	coefplot  ns2 s2, ///
	keep(WhiteMale_prev) mc(black) ciopts(color(black)) msymbol(d) xline(0, lc(gray)) level(95) grid(none) xlab(-.4(.2).4, labs(small) format(%2.1f)) msize(small) xsca(r(-.5 .45))  ysca(off) xtitle("b(After White Man)", size(med) margin(t=1)) legend(order(2  "HSB Industries" 4 "STEM Industries" ) col(1) pos(9) size(med) rowg(20) region(color(none) margin(b=3))) name(wm_prev, replace)  mlabel mlabpos(12) format(%4.3f) mlabgap(*2) mlabsize(medlarge) msize(med) title("(b) Effect of Being After a White Man	", size(medlarge) margin(b=10)) graphregion(margin(l=5 r=1)) mlabc(black)

	graph combine wm wm_prev, ycomm 
	graph display, ysize(10) xsize(15)
  	graph export "./output/Fig2_by_industry.pdf", replace 
	
**================**
** Tab 2 & Fig A.3
**================**

use "IRR_cleaned_data.dta", clear 

	sort subjectid resumenum 
	foreach x in WhiteMale LQWhiteMale LQType{
		forvalues j=1/5{
  			qui gen `x'_Lag`j'=`x'[_n-`j'] if subjectid==subjectid[_n-`j'] 
 		}
	}
 	qui gen WhiteMale_NN=( WhiteMale_Lag2==0 &  WhiteMale_Lag1==0)
 	qui gen WhiteMale_NY=( WhiteMale_Lag2==0 &  WhiteMale_Lag1==1)
	qui gen WhiteMale_YY=( WhiteMale_Lag2==1 &  WhiteMale_Lag1==1)
	qui gen WhiteMale_YN=( WhiteMale_Lag2==1 &  WhiteMale_Lag1==0)
	
  	qui gen LQWhiteMale_NN=( LQWhiteMale_Lag2==0 &  LQWhiteMale_Lag1==0)
 	qui gen LQWhiteMale_NY=( LQWhiteMale_Lag2==0 &  LQWhiteMale_Lag1==1)
	qui gen LQWhiteMale_YY=( LQWhiteMale_Lag2==1 &  LQWhiteMale_Lag1==1)
	qui gen LQWhiteMale_YN=( LQWhiteMale_Lag2==1 &  LQWhiteMale_Lag1==0)
	qui gen LQWhiteMale_YYY=(LQWhiteMale_Lag3==1 & LQWhiteMale_Lag2==1 &  LQWhiteMale_Lag1==1)

	lab var WhiteMale_Lag2 "$\text{WM}_{j-2}$"
	lab var WhiteMale_Lag1 "$\text{WM}_{j-1}$"
	lab var WhiteMale_NY "$\text{Other}_{j-2}$, $\text{WM}_{j-1}$"
	lab var WhiteMale_YN "$\text{WM}_{j-1}$, $\text{Other}_{j-2}$"
	lab var WhiteMale_YY "$\text{WM}_{j-1}$, $\text{WM}_{j-2}$"
	lab var LQWhiteMale_Lag2 "$\text{LQWM}_{j-2}$"
	lab var LQWhiteMale_Lag1 "$\text{LQWM}_{j-1}$"
	lab var LQWhiteMale_NY "$\text{Other}_{j-2}$, $\text{LQWM}_{j-1}$"
	lab var LQWhiteMale_YN "$\text{LQWM}_{j-1}$, $\text{Other}_{j-2}$"
	lab var LQWhiteMale_YY "$\text{LQWM}_{j-1}$, $\text{LQWM}_{j-2}$"
	
	keep if resumenum>2  

	** Tab 2: 
	local name Tab2_Dynamic_Effect  
	qui reghdfe rating_hire WhiteMale_Lag2 WhiteMale_Lag1  $dem $ctr, a($fe) vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(WhiteMale*) ctitle(" ") replace nonotes
	
	qui reghdfe rating_hire WhiteMale_NY WhiteMale_YN WhiteMale_YY  $dem $ctr, a($fe) vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(WhiteMale*) ctitle(" ") 
	
	qui reghdfe rating_hire LQWhiteMale_Lag2 LQWhiteMale_Lag1  $dem $ctr, a($fe) vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(LQWhiteMale*) ctitle(" ")  
	
	qui reghdfe rating_hire LQWhiteMale_NY LQWhiteMale_YN LQWhiteMale_YY $dem $ctr, a($fe) vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(LQWhiteMale*) ctitle(" ") sortvar(WhiteMale_Lag2 WhiteMale_Lag1 WhiteMale_NY WhiteMale_YN WhiteMale_YY LQWhiteMale_Lag2 LQWhiteMale_Lag1 LQWhiteMale_NY LQWhiteMale_YN LQWhiteMale_YY)
	
	** Figure A.3: 
	forvalues i=1/5{
		qui gen Lag`i'=WhiteMale_Lag`i' 
	}
	eststo l1: qui reghdfe rating_hire Lag1 $dem $ctr, a($fe)  vce(r)
	eststo l2: qui reghdfe rating_hire Lag2 Lag1 $dem $ctr, a($fe)  vce(r)
	eststo l3: qui reghdfe rating_hire Lag3 Lag2 Lag1 $dem $ctr, a($fe)  vce(r)
	eststo l4: qui reghdfe rating_hire Lag4 Lag3 Lag2 Lag1 $dem $ctr, a($fe)  vce(r)
	eststo l5: qui reghdfe rating_hire Lag5 Lag4 Lag3 Lag2 Lag1 $dem $ctr , a($fe)  vce(r)
	
	forvalues i=1/5{
		qui replace Lag`i'=LQWhiteMale_Lag`i' 
	}
	eststo L1: qui reghdfe rating_hire Lag1 $dem $ctr, a($fe)  vce(r)
	eststo L2: qui reghdfe rating_hire Lag2 Lag1 $dem $ctr, a($fe)  vce(r)
	eststo L3: qui reghdfe rating_hire Lag3 Lag2 Lag1 $dem $ctr, a($fe)  vce(r)
	eststo L4: qui reghdfe rating_hire Lag4 Lag3 Lag2 Lag1 $dem $ctr, a($fe)  vce(r)
	eststo L5: qui reghdfe rating_hire Lag5 Lag4 Lag3 Lag2 Lag1 $dem $ctr , a($fe)  vce(r)
	
	coefplot 	(l5, keep(Lag5)  mc(black) ciopts(col(black))) ///
				(L5, keep(Lag5)  m(d) mc(black*.7) ciopts(col(black*.7))) ///
				(l4, keep(Lag4)  mc(black) ciopts(col(black))) ///
				(L4, keep(Lag4)  m(d) mc(black*.7) ciopts(col(black*.7))) ///
				(l3, keep(Lag3)  mc(black) ciopts(col(black))) ///
				(L3, keep(Lag3)  m(d) mc(black*.7) ciopts(col(black*.7))) ///
				(l2, keep(Lag2)  mc(black) ciopts(col(black))) ///
				(L2, keep(Lag2)  m(d) mc(black*.7) ciopts(col(black*.7))) ///
				(l1, keep(Lag1)  mc(black) ciopts(col(black))) ///
				(L1, keep(Lag1)  m(d) mc(black*.7) ciopts(col(black*.7))) ///
		 , level(95) vertical yline(0, lc(gray)) xtitle("(Low-Quality) White Man", margin(t=2) size(medsmall)) ylab(-.6(.3).3, format(%2.1f) labsize(small)) xsca(r(-.25 6.25)) xlab(.7 "{it:j-5}" 1.8 "{it:j-4}" 3 "{it:j-3}" 4.2 "{it:j-2}" 5.3 "{it:j-1}") legend(order(2 "White Man" 4 "Low-Quality White Man") size(small) pos(12) region(color(none))) msize(medsmall)
	graph export "./output/FigA3_Dynamics.pdf" , replace 

	
**================**
** Tab A.2 & A.4
**================**

use "IRR_cleaned_data.dta", clear 

	foreach x in WhiteMale WhiteName MaleName whitemale_emp white_emp male_emp HQType HDiversity Diversity Quality{
		gen WhiteMale_prev_`x'=WhiteMale_prev*`x'
		gen LQWhiteMale_prev_`x'=LQWhiteMale_prev*`x'
	}
	
	lab var WhiteMale_prev_whitemale "After White Male $\times$ White Male Employer"
	lab var LQWhiteMale_prev_whitemale "After LQWM $\times$ White Male Employer" 
	lab var LQWhiteMale_prev "After Low-Quality White Man (LQWM)"
	lab var LQWhiteMale_prev_WhiteMale "After LQWM $\times$ White Male Resume"
	lab var WhiteMale_prev_WhiteMale "After White Male $\times$ White Male Resume"
 	lab var WhiteMale_prev_HQType "After White Male $\times$ High-Quality Resume"
	lab var WhiteMale_prev_HDiversity "After White Male $\times$ High-Diversity Employer"
 	lab var LQWhiteMale_prev_HQType "After LQWM $\times$ High-Quality Resume"
	lab var LQWhiteMale_prev_HDiversity "After LQWM $\times$ High-Diversity Employer"
	lab var WhiteMale_prev_Quality "After White Male $\times$ Std. Resume Quality"
	lab var LQWhiteMale_prev_Quality "After LQWM $\times$ Std. Resume Quality"
	lab var WhiteMale_prev_Diversity "After White Male $\times$ Std. Diversity Importance "
	lab var LQWhiteMale_prev_Diversity "After LQWM $\times$ Importance of Diversity"
	lab var WhiteMale_prev_HDiversity "After White Male $\times$ High Importance of Diversity"
	lab var LQWhiteMale_prev_HDiversity "After LQWM $\times$ High Importance of Diversity"

	** Tab A.2: After White Man 
	local name TabA2_Heterogeneity_raw
	qui reghdfe rating_hire WhiteMale_prev WhiteMale_prev_WhiteMale $dem $ctr , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag)  dec(3)  nocons label keep(WhiteMale*)  ctitle(" ") replace  

	qui reghdfe rating_hire WhiteMale_prev WhiteMale_prev_Quality Quality $dem $ctr , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag)  dec(3)  nocons label keep(WhiteMale*)  ctitle(" ")  
	
	qui reghdfe rating_hire WhiteMale_prev WhiteMale_prev_HQType HQType $dem $ctr , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag)  dec(3)  nocons label keep(WhiteMale*)  ctitle(" ")   

	qui reghdfe rating_hire WhiteMale_prev WhiteMale_prev_whitemale $ctr $dem , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag)  dec(3)  nocons label keep(WhiteMale*) ctitle(" ")

	qui reghdfe rating_hire WhiteMale_prev WhiteMale_prev_Diversity $ctr $dem , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag)  dec(3)  nocons label keep(WhiteMale*) ctitle(" ")
	
	qui reghdfe rating_hire WhiteMale_prev WhiteMale_prev_HDiversity $ctr $dem , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag)  dec(3)  nocons label keep(WhiteMale*) ctitle(" ")

	** Tab A.4: After LQ White Man 
	local name TabA4_Heterogeneity_raw 
	qui reghdfe rating_hire LQWhiteMale_prev LQWhiteMale_prev_WhiteMale $dem $ctr , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(LQWhiteMale* WhiteMale*)  ctitle(" ")  replace 
	
	qui reghdfe rating_hire LQWhiteMale_prev LQWhiteMale_prev_Quality Quality $dem $ctr , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(LQWhiteMale* WhiteMale* HQType)  ctitle(" ")  
	
 	qui reghdfe rating_hire LQWhiteMale_prev LQWhiteMale_prev_HQType HQType $dem $ctr , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(LQWhiteMale* WhiteMale* HQType)  ctitle(" ")  

	qui reghdfe rating_hire LQWhiteMale_prev LQWhiteMale_prev_whitemale $ctr $dem , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(LQWhiteMale*) ctitle(" ") 
	
 	qui reghdfe rating_hire LQWhiteMale_prev LQWhiteMale_prev_Diversity $ctr $dem , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(LQWhiteMale*) ctitle(" ") 

 	qui reghdfe rating_hire LQWhiteMale_prev LQWhiteMale_prev_HDiversity $ctr $dem , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(LQWhiteMale*) ctitle(" ") 

	
**==================================================**
** Tab A.3: No Evidence on Quality Spillover Effects 
**==================================================**	
	
use "IRR_cleaned_data.dta", clear 
	
 	local name TabA3_Quality_Spillover 
	qui reghdfe rating_hire randgpa_prev $ctr $dem, a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(*_prev) ctitle(" ") replace  nonotes 
	
	foreach x in topemp secondint wfm techskills LQType  {
	qui reghdfe rating_hire `x'_prev $ctr $dem , a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag) dec(3)  nocons label keep(*_prev) ctitle(" ")
	}
	
	qui reghdfe rating_hire randgpa_prev topemp_prev secondint_prev wfm_prev techskills_prev $ctr $dem, a($fe)  vce(r)
	outreg2 using "./output/`name'.tex", tex(frag)  dec(3)  nocons label keep(*_prev) ctitle(" ")	
	
	
**==================================================**
** Tab A.5: Placebo Test 
**==================================================**	
use "IRR_cleaned_data.dta", clear 

	sort subjectid resumenum 
	gen WhiteMale_Lead1=WhiteMale[_n+1] if subjectid==subjectid[_n+1]
	gen LQWhiteMale_Lead1=LQWhiteMale[_n+1] if subjectid==subjectid[_n+1]
	gen HQWhiteMale_Lead1=HQWhiteMale[_n+1] if subjectid==subjectid[_n+1]
	
	lab var WhiteMale_prev "After White Male"
	lab var WhiteMale_Lead1 "Before White Male"
	lab var LQWhiteMale_prev "After Low-Quality White Male"
	lab var LQWhiteMale_Lead1 "Before Low-Quality White Male"
	lab var HQWhiteMale_prev "After High-Quality White Male"
	lab var HQWhiteMale_Lead1 "Before High-Quality White Male"
	
 	local name TabA5_Placebo_Test
	qui reghdfe rating_hire WhiteMale_prev WhiteMale_Lead1 $ctr $dem, a($fe) vce(r)
		outreg2 using "./output/`name'.tex", tex(frag) dec(3) keep(*prev *Lead1) replace nocons nonotes ctitle(" ") label
		
	qui reghdfe rating_hire LQWhiteMale_prev LQWhiteMale_Lead1 $ctr $dem, a($fe) vce(r)
		outreg2 using "./output/`name'.tex", tex(frag) dec(3) keep(*prev *Lead1) nocons ctitle(" ") label
		
	qui reghdfe rating_hire HQWhiteMale_prev HQWhiteMale_Lead1 $ctr $dem, a($fe) vce(r)
		outreg2 using "./output/`name'.tex", tex(frag) dec(3) keep(*prev *Lead1) nocons ctitle(" ") label
 	
	qui reghdfe rating_hire WhiteMale_Lead1 $ctr $dem, a($fe) vce(r)
		outreg2 using "./output/`name'.tex", tex(frag) dec(3) keep(*prev *Lead1) nocons ctitle(" ") label
		
	qui reghdfe rating_hire LQWhiteMale_Lead1 $ctr $dem, a($fe) vce(r)
		outreg2 using "./output/`name'.tex", tex(frag) dec(3) keep(*prev *Lead1) nocons ctitle(" ") label
		
	qui reghdfe rating_hire HQWhiteMale_Lead1 $ctr $dem, a($fe) vce(r)
		outreg2 using "./output/`name'.tex", tex(frag) dec(3) keep(*prev *Lead1) nocons	 ctitle(" ") label
		
**==================================================**
** Tab A.6: Different Inference Methods
**==================================================**			

use "IRR_cleaned_data.dta", clear 

	** After White Man
	reghdfe rating_hire WhiteMale_prev $dem $ctr, a($fe) vce(r)
	//SE=.0847362. pval= 0.026 
	reghdfe rating_hire WhiteMale_prev $dem $ctr, a($fe) vce(cl subjectid)
	//SE=.0792114, pval= 0.020
	bootstrap, reps(1000) seed($seed) nodots: reghdfe rating_hire WhiteMale_prev $dem $ctr, a($fe)
	//SE=.0861867, pval=0.028
	bootstrap, reps(1000) seed($seed) nodots cluster(subjectid): reghdfe rating_hire WhiteMale_prev $dem $ctr, a($fe)
	//SE=.0815357, pval=0.021
	jacknife, nodots: reghdfe rating_hire WhiteMale_prev $dem $ctr, a($fe)
	//SE=.0897594, pval=0.035
	jacknife, nodots cluster(subjectid): reghdfe rating_hire WhiteMale_prev $dem $ctr, a($fe)
	//SE=.0832224, pval= 0.026
	
	** After Low-Quality White Man
	reghdfe rating_hire LQWhiteMale_prev $dem $ctr, a($fe) vce(r)
	//SE=.119895, pval=0.010
	reghdfe rating_hire LQWhiteMale_prev $dem $ctr, a($fe) vce(cl subjectid)
	//SE=.1131503, pval=0.008 
	bootstrap, reps(1000) seed($seed) nodots: reghdfe rating_hire LQWhiteMale_prev $dem $ctr, a($fe)
	//SE=.1222801, pval=0.012
	bootstrap, reps(1000) seed($seed) nodots cluster(subjectid): reghdfe rating_hire LQWhiteMale_prev $dem $ctr, a($fe)
	//SE=.1125473, pval=0.006
	jacknife, nodots: reghdfe rating_hire LQWhiteMale_prev $dem $ctr, a($fe)
	//SE=.1272777, pval=0.015
	jacknife, nodots cluster(subjectid): reghdfe rating_hire LQWhiteMale_prev $dem $ctr, a($fe)
	//SE=.1195285, pval=0.012
	
**==================================================**
** Tab A.7: Lasso Model Selection
**==================================================**			
	
use "IRR_cleaned_data.dta", clear 

 	qui reg rating_hire i.subjectid 
	predict rating_res, residuals 
	foreach x in lead1 lead2 resumenum majorid subjectid{
	qui tab `x', gen(`x'_)
	}
	
	local fes lead1_* lead2_* resumenum_* majorid_*
	local prev WhiteMale_prev randgpa_prev topemp_prev secondint_prev wfm_prev techskills_prev WhiteFemale MinorityMale MinorityFemale 
	lasso linear rating_res `prev' $ctr `fes', selection(adaptive, ridge) rseed($seed) nolog
	estimates store adaptive  
 	lasso linear rating_res `prev' $ctr `fes', selection(cv)  rseed($seed) nolog 
	estimates store cv  
 	lasso linear rating_res `prev' $ctr `fes', selection(bic, all) rseed($seed)  nolog 
	estimates store bic 	
	
	lassocoef adaptive cv bic, sort(coef, standardized) noleg display(coef, postselection) nofvlabel  
	lassogof adaptive cv bic , postselection
	
**==================================================**
** Table A.8 Test of Independence
**==================================================**

use "IRR_cleaned_data.dta", clear 
	tab rand_eth, gen(Race_)
	
	qui tabulate rand_eth Female , chi2 
 	dis `r(p)' 
	
	reg randgpa Female Race_1 Race_2 Race_4 
	test Female 
	test Race_1 Race_2 Race_4

	foreach x in majorid topemp secondint wfm techskills {
	qui tabulate `x' Female , chi2 
 	dis `r(p)' 
	qui tabulate `x' rand_eth , chi2 
 	dis `r(p)' 	
	}
	
**==================================================**
** Tab A.9: MHT 
**==================================================**			
use "IRR_cleaned_data.dta", clear 
	
*1. Romano-Wolf 	
rwolf2 ///
	(reg rating_hire WhiteMale_prev $ctr $dem $fe, vce(r) ) ///
	(reg rating_hire LQType_prev $ctr $dem $fe, vce(r) ) ///
	(reg rating_hire LQWhiteMale_prev $ctr $dem $fe, vce(r) ) ///
	,  indepvars(WhiteMale_prev, LQType_prev, LQWhiteMale_prev) seed($seed) reps(1000) nodots  

*2. Romano-Wolf (with clustering)		
rwolf2 ///
	(reg rating_hire WhiteMale_prev $ctr $dem $fe, vce(r) ) ///
	(reg rating_hire LQType_prev $ctr $dem $fe, vce(r) ) ///
	(reg rating_hire LQWhiteMale_prev $ctr $dem $fe, vce(r) ) ///
	,  indepvars(WhiteMale_prev, LQType_prev, LQWhiteMale_prev) seed($seed) reps(1000) nodots cluster(subjectid) idcluster(id)	

*3. Westfall-Young 
wyoung, cmd( ///
	"reghdfe rating_hire WhiteMale_prev $ctr $dem , a($fe) vce(r)" ///
	"reghdfe rating_hire LQType_prev $ctr $dem , a($fe) vce(r)" ///
	"reghdfe rating_hire LQWhiteMale_prev $ctr $dem , a($fe) vce(r)" ///
	) familyp("WhiteMale_prev"  "LQType_prev" "LQWhiteMale_prev") bootstraps(1000) seed($seed)  	
	
*4. Westfall-Young (with clustering)			
wyoung, cmd( ///
	"reghdfe rating_hire WhiteMale_prev $ctr $dem , a($fe) vce(r)" ///
	"reghdfe rating_hire LQType_prev $ctr $dem , a($fe) vce(r)" ///
	"reghdfe rating_hire LQWhiteMale_prev $ctr $dem , a($fe) vce(r)" ///
	) familyp("WhiteMale_prev"  "LQType_prev" "LQWhiteMale_prev") bootstraps(1000) seed($seed) cluster(subjectid) 	
 